import request from '@/utils/request';

export interface GetSellerParamsType {
    uId: string;
    userType: string;
    token: string;
    page: number;
    limit: number;
    select?: string;
	orderBy?: string;
	is_hava_device?: string | number;
	sid?: string | number;
	aid?: string | number;
	aname: string;
	order_by?: string | number;
}

// 获取商户
export function getSeller(data: GetSellerParamsType) {
	return request.post('/AgencyAdmin/Agency/getSeller', {
		data: {
			uId: data.uId,
			userType: data.userType,
			token: data.token,
			select: data.select,
			orderBy: data.orderBy,
			is_hava_device: data.is_hava_device,
			page: data.page,
			limit: data.limit,
			aid: data.aid,
			aname: data.aname,
			sid: data.sid,
			order_by: data.order_by,
		}
	})
}

export interface SellerStatisticsParamsType {
	uId: string;
	userType: string;
	token: string;
	sname?: string;
	page: number;
	limit: number;
	sid?: number | string;
	aid?: number | string;
	aname?: string;
}

// 商户统计 
export function sellerStatistics(data: SellerStatisticsParamsType) {
	return request.post('/AgencyAdmin/Agency/sellerStatistics', {
		data: {
			...data,
		}
	})
}

export interface GetSellerInfoParamsType {
	uId: string;
	userType: string;
	token: string;
	sId?: string; // 商户id
}

// 获取商户信息 
export async function getSellerInfo(data: GetSellerInfoParamsType) {
	return request.post('/AgencyAdmin/Seller/getUserInfo', {
		data: {
			...data,
		}
	})
}


export interface EditSellerParamsType extends GetSellerInfoParamsType {
	sId: string;
	name?: string;
	contacts?: string;
	phone?: string;
	addr?: string;
	latitude?: string;
	longitude?: string;
	rate_mode?: number;
	wx_leasing_mode?: number;
	wx_pb_leasing_mode?: number;
	zfb_leasing_mode?: number;
    zfb_pb_leasing_mode?: number;
    billingtime?: number; 
    billingunit?: number;
    amount?: string;
    freetime?: string;
    ceiling?: string;
	deposit?: string;
	wired_amount?: string; // 充电线套餐
	wired_deposit?: string; // 充电线封顶
	wired_pay_score_start_amount?: string; // 免押规则
	wired_pay_score_amount?: string; // 免押规则
}

// 修改商户信息
export async function editSeller(data: EditSellerParamsType) {
	return request.post('/AgencyAdmin/Seller/edit', {
		data: {
			...data
		}
	})
}


/**
 * 商户导出参数
 * @param {Number} uId 	用户编号
 * @param {Number} userType 用户类型 1-代理，2-商户
 * @param {string} token 访问令牌
 * @param {string} select 搜索条件(商户名称)
 * @param {string} aid 下级代理编号 传参则查询下级代理商户
 * @param {string} aname 		代理名称
 * @param {Number} is_hava_device 0-全部，1-已铺货，2-未铺货
 * @param {string} order_by 0-创建时间，1-充电宝使用率从高到低，2-充电宝使用率从低到高，3-充电线使用率从高到低，4-充电线使用率从低到高
 */
export interface sellerExportParams {
	uId: number
	userType: number
	token: string
	select: string
	aid: number | string
	aname: string
	is_hava_device: number | string
	order_by: number | string
}

/**
 * 导出商户
 * @param data 
 */
export async function sellerDataToCsvApi(data: sellerExportParams) {
    return request.post('/AgencyAdmin/Agency/sellerToCsv', {
        data: {
            ...data,
        }
    });
}
export interface DayUseRateParams {
	uId: string | number;
	userType: string | number;
	token: string;
	sid: string | number;
	type?: number;
	starttime?: string;
	endtime?: string;
	page: number;
	limit: number;
}

// 
export async function dayUseRate(data: DayUseRateParams) {
	return request.post('/AgencyAdmin/Seller/dayUseRate', {
		data: {
			...data
		}
	})
}

